package com.product.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author
 * @name：
 * @data:
 * @className:
 **/

@Configuration
public class SenderConfig {
    public static final String QUEUE_NAME = "direct.queue"; //队列名称
    public static final String EXCHANGE_NAME = "direct.exchange"; //交换器名称
    public static final String ROUTING_KEY = "pig"; //路由键

    /**
     * 队列
     *
     */
    @Bean
    public Queue queue() {
        return new Queue(QUEUE_NAME, true, false, false, null);
    }

   /* *
     * Direct交换器
     */
    @Bean
    public DirectExchange exchange() {
        return new DirectExchange(EXCHANGE_NAME, true, false);
    }

    /**
     * 绑定
     */
    @Bean
    Binding binding(DirectExchange exchange, Queue queue) {
        return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY);
    }

}
